﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DigitalPlatform.Common.Event;
using DigitalPlatform.Common.Mangaer;
using DigitalPlatform.ViewModels;
using Prism.Events;
using Prism.Mvvm;
using Unity;

namespace DigitalPlatform.Views
{
    /// <summary>
    /// MainView.xaml 的交互逻辑
    /// </summary>
    public partial class MainView : Window
    {
        private readonly IUnityContainer container;

        public IEventAggregator _eventAggregator { get; set; }
        public MainView(IEventAggregator eve, IUnityContainer container)
        {
            _eventAggregator = eve;
            this.container = container;
            InitializeComponent();
            _eventAggregator.GetEvent<Event_CloseMainWindow>().Subscribe(closewindow);
            _eventAggregator.GetEvent<Event_MinMainWindow>().Subscribe(minwindow);
            _eventAggregator.GetEvent<Event_MaxMainWindow>().Subscribe(maxwindow);

            ActionManager<bool>.Register("ShowCompConfig", ShowCompConfig);

        }
        public bool ShowCompConfig()
        {
            var view = container.Resolve<ComponentConfigView>();
            view.DataContext = container.Resolve<ConfigViewModel>();
            return view.ShowDialog() == true;
        }
        #region windowstate
        public void closewindow()
        {
            this.Close();
        }
        public void minwindow()
        {
            this.WindowState = WindowState.Minimized;
        }
        public void maxwindow()
        {
            this.WindowState = this.WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
        }
        #endregion

    }
}
